package dice.sinanya.tools.checkdata;

import com.forte.qqrobot.beans.messages.types.MsgGetTypes;
import dice.sinanya.entity.EntityTypeMessages;
import dice.sinanya.exceptions.NotMasterException;

import static dice.sinanya.tools.getinfo.GetMessagesProperties.entityBanProperties;

public class CheckPower {
    public static void checkMaster(EntityTypeMessages entityTypeMessages) throws NotMasterException {
        if (!entityBanProperties.getMaster().contains(entityTypeMessages.getFromQqString())) {
            throw new NotMasterException(entityTypeMessages);
        }
    }

    public static boolean checkMasterNotSend(EntityTypeMessages entityTypeMessages) {
        return entityBanProperties.getMaster().contains(entityTypeMessages.getFromQqString());
    }

    public static boolean checkMasterAndSendByPrNotSendByGroup(EntityTypeMessages entityTypeMessages) throws NotMasterException {
        if (entityTypeMessages.getMsgGetTypes().equals(MsgGetTypes.privateMsg)) {
            checkMaster(entityTypeMessages);
            return true;
        } else {
            return checkMasterNotSend(entityTypeMessages);
        }
    }
}
